package com.bdqn.tsyyds.controller;

import com.bdqn.tsyyds.entity.BookInfo;
import com.bdqn.tsyyds.entity.Permission;
import com.bdqn.tsyyds.repository.BookInfoRepostiory;
import com.bdqn.tsyyds.repository.PermissionRepository;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
@Controller
@RequestMapping("/borrow")
public class BorrowController {
    @Resource
    BookInfoRepostiory bookInfoRepostiory;

    @RequestMapping("/okok")
    @ResponseBody
    public Object okok(Model model) {
        System.out.println("进入了Controller的okok方法");
        List<BookInfo> list=bookInfoRepostiory.findAll();
        return list;
    }

    @RequestMapping("/returnList")

    public String ok(Model model) {
        List<BookInfo> bookInfos = bookInfoRepostiory.findAll();
        model.addAttribute("bookInfo",bookInfos);
        return "borrow/return";
    }

    @Resource
    PermissionRepository permissionRepository;


    @RequestMapping("/cspername")
    public String name(String name) {
        Permission permission = new Permission();
        permission.setPermissionName(name);
        permissionRepository.save(permission);
        return "borrow/return";
    }
}
